from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("http://baidu.com")
driver.find_element(By.ID,"kw").send_keys("javascript是什么")
driver.find_element(By.ID,"su").click()
sleep(2)
#当元素隐藏不可交互时
a = driver.find_element(By.ID,"kw")
driver.execute_script("arguments[0].setAttribute('style','display:none');",a)
#中断后检查当前窗口元素
input()
print(a.get_dom_attribute('style'))  #display:none
try:
    a.send_keys("Hello World")  #会报元素不可交互异常
except Exception as e:
    print("元素不可交互",e)
sleep(5)

#删除刚刚输入框添加的隐藏属性，能定位到可操作
driver.execute_script("arguments[0].removeAttribute('style');",a)
print(a.get_dom_attribute('style'))

